package DesignPatern.A22_享元模式.A01_基本模式;

import java.util.HashMap;

/**
 * @Author: Du
 * @Date: 2021/8/12 15:38
 */
public class SignInfoFactory
{
    
    private static HashMap<String, SignInfo> hashMap = new HashMap<>();
    
    public static SignInfo getSignInfo(String key)
    {
        SignInfo signInfo = null;
        
        if (!hashMap.containsKey(key))
        {
            signInfo = new SignInfoPool(key);
            hashMap.put(key, signInfo);
            System.out.println(key + "---新建立的对象");
        } else
        {
            signInfo = hashMap.get(key);
            System.out.println(key + "---直接从常量池中取出");
        }
        return signInfo;
    }
    //    public static SignInfo getSignInfo()
    //    {
    //        return new SignInfo();
    //    }
}
